//
//  GrbjVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/7.
//

import Foundation

extension GrbjVC {
    
    func initUI() {
        
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing3@1.5x"))
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH())
        }
        self.navTitle = "个人编辑"
        self.lgf_NavigationBar.lgf_Title?.textColor = UIColor.white
        
        scrollView = UIScrollView.lgf_Table("FFFFFF")
        if #available(iOS 11.0, *) {
            scrollView.contentInsetAdjustmentBehavior = .never
        } else {
            self.automaticallyAdjustsScrollViewInsets = false
        }
        view.addSubview(scrollView)
        scrollView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        
        let tx = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "", true)
        tx.lgf_ViewName = "头像"
        tx.delegate = self
        scrollView.addSubview(tx)
        tx.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label0 = UILabel.init()
        label0.text = "头像"
        label0.textColor = UIColor.init(lgf_HexString: "222222")
        label0.font = UIFont.boldSystemFont(ofSize: 16)
        tx.addSubview(label0)
        label0.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let image_view = UIImageView.init(image: #imageLiteral(resourceName: "zhuanhuan@1.5x"))
        tx.addSubview(image_view)
        image_view.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-30)
            make.width.height.equalTo(40)
        }
        
        let xm = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "用户姓名", text: "", false)
        xm.delegate = self
        scrollView.addSubview(xm)
        xm.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(tx.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label1 = UILabel.init()
        label1.text = "姓名"
        label1.textColor = UIColor.init(lgf_HexString: "222222")
        label1.font = UIFont.boldSystemFont(ofSize: 16)
        xm.addSubview(label1)
        label1.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        let xb = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "用户性别", text: "", true)
        xb.lgf_ViewName = "性别"
        xb.delegate = self
        scrollView.addSubview(xb)
        xb.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(xm.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label2 = UILabel.init()
        label2.text = "性别"
        label2.textColor = UIColor.init(lgf_HexString: "222222")
        label2.font = UIFont.boldSystemFont(ofSize: 16)
        xb.addSubview(label2)
        label2.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        let sj = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "11位手机号", text: "", false)
        sj.delegate = self
        scrollView.addSubview(sj)
        sj.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(xb.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label3 = UILabel.init()
        label3.text = "手机"
        label3.textColor = UIColor.init(lgf_HexString: "222222")
        label3.font = UIFont.boldSystemFont(ofSize: 16)
        sj.addSubview(label3)
        label3.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        let button1 = UIButton.init(type: .custom)
        button1.backgroundColor = UIColor.init(lgf_HexString: EWEDarkMode.c_0F88F2)!
        button1.setTitle("确定", for: .normal)
        button1.setTitleColor(EWEDarkMode.white(), for: .normal)
        button1.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        button1.layer.cornerRadius = 4
        button1.layer.masksToBounds = true
        button1.addTarget(self, action: #selector(GrbjVC.queding(_:)), for: .touchUpInside)
        scrollView.addSubview(button1)
        button1.snp.makeConstraints { (make) in
            make.top.equalTo(sj.snp.bottom).offset(200)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().offset(-75)
            make.height.equalTo(44)
        }
        
        scrollView.lgf_AutoContentSize(0)
    }
    
}

extension GrbjVC: LGFLoginImageTitleViewDelegate {
    func selectLGFLoginImageTitleView(_ view: LGFLoginImageTitleView) {
        self.view.endEditing(true)
        if view.lgf_ViewName == "性别" {
            let picker = LGFBottomPickerView()
            let data = ["男", "女"]
//            let sindex = data.lgf_IndexOfObject(self.xb.textField.text ?? "男")
            picker.showIn(self.view, data, 0) { (view, name, index) in
                
            }
        }
    }
}
